package com.hyjr.RxTask.demo;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

public class DcTaskScheduler implements RxBaseService {
	private static DcTaskScheduler _dctaskScheduler = null;
	private volatile boolean isRunning = true;

	public static DcTaskScheduler GetInstance() {
		if (_dctaskScheduler == null) {
			_dctaskScheduler = new DcTaskScheduler();
			// obj = new object();
		}
		return _dctaskScheduler;
	}

	public void run() {
		BlockingQueue<RxMsg> queue = RxMsgController.GetInstance().GetRxMsgQueue();
		while (isRunning) {
			try {
				RxMsg rxMsg = queue.take();
				if(rxMsg != null) {
					System.out.println("消费数据：" + rxMsg.toString());
				} else {
					System.out.println("未获取到数据！");
				}
			} catch (InterruptedException e) {
				System.out.println("获取数据失败！");
			}
		}
	}

	public void stop() {
		isRunning = false;
	}
}
